package com.xbongbong.pro.domain.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.saas.domain.entity.StageWorkEntity;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * 备份阶段任务表
 * 
 * @author mingliang.cao
 * 
 * @date 2021-11-16
 */
@Getter
@Setter
public class StageWorkRetainEntity implements Serializable {
    private static final long serialVersionUID = 5189928081309469011L;
    /**
     * 主键
     */
    private Long id;

    /**
     *
     */
    private String corpid;

    /**
     * 备份应用Id, 用来区别同公司同应用同表单的多次备份
     */
    private Long retainAppId;

    /**
     * 备份表单id
     */
    private Long retainFormId;

    /**
     * 备份阶段流程id
     */
    private Long retainStageProcessId;

    /**
     * 备份阶段任务id
     */
    private Long retainStageWorkId;

    /**
     * 备份阶段id
     */
    private Long retainStageId;

    /**
     * 阶段code
     */
    private String stageCode;

    /**
     * 关联类型
     */
    private Integer businessType;

    /**
     * 区分SaaS业务还是PaaS业务（1SaaS、2PaaS）
     */
    private Integer saasMark;

    /**
     * 任务名称
     */
    private String name;

    /**
     * 任务描述
     */
    private String description;

    /**
     * 任务占比
     */
    private Integer proportion;

    /**
     * 任务是否必填（0不必填、1必填）
     */
    private Integer required;

    /**
     * 执行事件
     */
    private JSONObject executionEvent;

    /**
     * 执行人，空值代表所有人都允许执行
     */
    private JSONArray executor;

    /**
     * 任务完成条件
     */
    private JSONArray completionCondition;

    /**
     * 任务排序【sort值越大代表任务越靠前】
     */
    private Integer sort;

    /**
     * 创建人
     */
    @Deprecated
    private String creatorId;

    /**
     * 创建时间
     */
    private Long addTime;

    /**
     * 更新时间
     */
    private Long updateTime;

    /**
     * 删除标记
     */
    private Integer del;

    public StageWorkRetainEntity() {
        del = 0;
    }

    public StageWorkRetainEntity(StageWorkEntity item, Long retainAppId) {
        this.corpid = item.getCorpid();
        this.retainAppId = retainAppId;
        this.retainFormId = item.getFormId();
        this.retainStageProcessId = item.getStageProcessId();
        this.retainStageWorkId = item.getStageId();
        this.retainStageId = item.getStageId();
        this.stageCode = item.getStageCode();
        this.businessType = item.getBusinessType();
        this.saasMark = item.getSaasMark();
        this.name = item.getName();
        this.description = item.getDescription();
        this.proportion = item.getProportion();
        this.required = item.getRequired();
        this.executionEvent = item.getExecutionEvent();
        this.executor = item.getExecutor();
        this.completionCondition = item.getCompletionCondition();
        this.sort = item.getSort();
//        this.creatorId = ;
        this.addTime = item.getAddTime();
        this.updateTime = item.getUpdateTime();
        this.del = item.getDel();
    }
}